package com.hilinos.ftp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hilinos.ftp.mapper.ConfigMapper;
import com.hilinos.ftp.pojo.ConfigPojo;
import com.hilinos.ftp.service.ConfigService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, ConfigPojo> implements ConfigService {
    @Override
    public void edit(List<ConfigPojo> configs) {
        updateBatchById(configs);
    }

    @Override
    public String getValue(String keyid) {
        return getById(keyid).getData();
    }


    @Override
    public List<ConfigPojo> getAllUserConfig() {
        QueryWrapper<ConfigPojo> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda()
                .eq(ConfigPojo::getOpen, 1);
        return list(queryWrapper);
    }
}
